package com.xintonghua.bussiness.ui.fragment.client;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xintonghua.base.widget.MyItemTextView;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.BaseActivity;
import com.xintonghua.bussiness.bean.Contant;
import com.xintonghua.bussiness.util.JumpUtils;
import com.xintonghua.bussiness.util.MyState;

import org.json.JSONObject;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by liqi on 2018/3/30.
 * 档案
 */
public class ArchivesActivity extends BaseActivity implements initTab {
    @BindView(R.id.tabOrder)
    TabLayout tabOrder;
    Contant contantbean;
    @BindView(R.id.tv_top_1)
    TextView tvTop1;
    @BindView(R.id.tv_top_2)
    TextView tvTop2;
    @BindView(R.id.tv_top_3)
    TextView tvTop3;
    @BindView(R.id.tv_top_4)
    TextView tvTop4;
    @BindView(R.id.ll_top)
    LinearLayout llTop;

    @BindView(R.id.et_bottom1)
    EditText etBottom1;
    @BindView(R.id.ll_bottom1)
    LinearLayout llBottom1;
    @BindView(R.id.et_bottom2)
    EditText etBottom2;
    @BindView(R.id.ll_bottom2)
    LinearLayout llBottom2;

    List<MyItemTextView> list;
    @BindView(R.id.mtv_0_fuwushijian)
    MyItemTextView mtv0Fuwushijian;
    @BindView(R.id.mtv_1_dianpu)
    MyItemTextView mtv1Dianpu;
    @BindView(R.id.mtv_2_fuwuxiangmu)
    MyItemTextView mtv2Fuwuxiangmu;
    @BindView(R.id.mtv_3_caozuofangshi)
    MyItemTextView mtv3Caozuofangshi;
    @BindView(R.id.mtv_4_fuwuyuangong)
    MyItemTextView mtv4Fuwuyuangong;
    @BindView(R.id.mtv_5_jianzhongcishu)
    MyItemTextView mtv5Jianzhongcishu;
    @BindView(R.id.mtv_6_jianzhonghoutizhong)
    MyItemTextView mtv6Jianzhonghoutizhong;
    @BindView(R.id.mtv_7_jianzhonghoufuyao)
    MyItemTextView mtv7Jianzhonghoufuyao;
    @BindView(R.id.mtv_8_jianzhongchicun)
    MyItemTextView mtv8Jianzhongchicun;
    @BindView(R.id.mtv_9_jianzhonghoudatui)
    MyItemTextView mtv9Jianzhonghoudatui;
    @BindView(R.id.mtv_10_jianzhongchicun)
    MyItemTextView mtv10Jianzhongchicun;
    @BindView(R.id.mtv_11_xiacihullitime)
    MyItemTextView mtv11Xiacihullitime;
    @BindView(R.id.mtv_12_xiangmucishu)
    MyItemTextView mtv12Xiangmucishu;
    @BindView(R.id.mtv_13_xiaohaocishu)
    MyItemTextView mtv13Xiaohaocishu;
    @BindView(R.id.mtv_14_xiaohaoshijian)
    MyItemTextView mtv14Xiaohaoshijian;
    @BindView(R.id.mtv_15_shengyucishu)
    MyItemTextView mtv15Shengyucishu;
    @BindView(R.id.mtv_16_fuwuyuangong)
    MyItemTextView mtv16Fuwuyuangong;
    @BindView(R.id.mtv_17_huliqiangkuang)
    MyItemTextView mtv17Huliqiangkuang;
    @BindView(R.id.mtv_18_jianyifangan)
    MyItemTextView mtv18Jianyifangan;
    @BindView(R.id.mtv_72_jianzhonghoushoubi)
    MyItemTextView mtv72Jianzhonghoushoubi;
    @BindView(R.id.mtv_82_jianzhongchicun)
    MyItemTextView mtv82Jianzhongchicun;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_archives);
        onSimpleActionBar(R.layout.activity_tab_actionbar_simple);
        ButterKnife.bind(this);
        changeToYangsheng();
        contantbean = (Contant) JumpUtils.getSerializable(this);
        initTabLayout();
        initUI();
    }

    @Override
    public void initUI() {
        super.initUI();
    }

    int mCurPage = 1;//1会员签字  2店长签字

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void initTabLayout() {

        tabOrder.addTab(tabOrder.newTab().setText("美容养生"));
        tabOrder.addTab(tabOrder.newTab().setText("减肥"));
        tabOrder.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                if (tab.getPosition() == 0) {
                    changeToYangsheng();
                } else if (tab.getPosition() == 1) {
                    changeToJianFei();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }
//        mtv11Xiacihullitime.setVisibility(View.GONE);
    @Override
    public void changeToJianFei() {


        llTop.setVisibility(View.VISIBLE);
        mtv3Caozuofangshi.setVisibility(View.VISIBLE);
        mtv4Fuwuyuangong.setVisibility(View.VISIBLE);
        mtv5Jianzhongcishu.setVisibility(View.VISIBLE);

        mtv6Jianzhonghoutizhong.setVisibility(View.VISIBLE);
        mtv7Jianzhonghoufuyao.setVisibility(View.VISIBLE);

        mtv72Jianzhonghoushoubi.setVisibility(View.VISIBLE);
        mtv82Jianzhongchicun.setVisibility(View.VISIBLE);
        mtv8Jianzhongchicun.setVisibility(View.VISIBLE);
        mtv9Jianzhonghoudatui.setVisibility(View.VISIBLE);
        mtv10Jianzhongchicun.setVisibility(View.VISIBLE);





        mtv12Xiangmucishu.setVisibility(View.GONE);
        mtv13Xiaohaocishu.setVisibility(View.GONE);
        mtv14Xiaohaoshijian.setVisibility(View.GONE);
        mtv15Shengyucishu.setVisibility(View.GONE);
        mtv16Fuwuyuangong.setVisibility(View.GONE);
        mtv17Huliqiangkuang.setVisibility(View.GONE);
        mtv18Jianyifangan.setVisibility(View.GONE);
        llBottom1.setVisibility(View.VISIBLE);
        llBottom2.setVisibility(View.VISIBLE);

    }

    @Override
    public void changeToYangsheng() {
        llTop.setVisibility(View.GONE);
        mtv3Caozuofangshi.setVisibility(View.GONE);
        mtv4Fuwuyuangong.setVisibility(View.GONE);
        mtv5Jianzhongcishu.setVisibility(View.GONE);

        mtv6Jianzhonghoutizhong.setVisibility(View.GONE);
        mtv7Jianzhonghoufuyao.setVisibility(View.GONE);

        mtv72Jianzhonghoushoubi.setVisibility(View.GONE);
        mtv82Jianzhongchicun.setVisibility(View.GONE);
        mtv8Jianzhongchicun.setVisibility(View.GONE);
        mtv9Jianzhonghoudatui.setVisibility(View.GONE);
        mtv10Jianzhongchicun.setVisibility(View.GONE);


        mtv12Xiangmucishu.setVisibility(View.VISIBLE);
        mtv13Xiaohaocishu.setVisibility(View.VISIBLE);
        mtv14Xiaohaoshijian.setVisibility(View.VISIBLE);
        mtv15Shengyucishu.setVisibility(View.VISIBLE);
        mtv16Fuwuyuangong.setVisibility(View.VISIBLE);
        mtv17Huliqiangkuang.setVisibility(View.VISIBLE);
        mtv18Jianyifangan.setVisibility(View.VISIBLE);
        llBottom1.setVisibility(View.GONE);
        llBottom2.setVisibility(View.VISIBLE);
    }


    @Override
    public void dataBack(Object data, int order) {
        super.dataBack(data, order);
        Log.i("aaa", "data===>" + data + "order====>" + order);
        switch (order) {
            case MyState.requestOne:
                try {
                    JSONObject js = new JSONObject(data.toString());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;

        }


    }


}

interface initTab {
    //tab
    void initTabLayout();

    void changeToJianFei();

    void changeToYangsheng();
}